import request from '../utils/request';
import { API } from '../utils/config';

/**
 * 获取广告列表
 * @param params 查询参数
 * @returns 返回广告列表数据
 */
export const getAdvertisementList = (params?: any) => {
  return request({
    url: `${API.CLASSES}/Advertisement`,
    method: 'GET',
    params: {
      order: '-createdAt',
      ...params
    }
  });
};

/**
 * 创建广告
 * @param data 广告数据
 */
export const createAdvertisement = (data: any) => {
  return request({
    url: `${API.CLASSES}/Advertisement`,
    method: 'POST',
    data
  });
};

/**
 * 更新广告
 * @param id 广告ID
 * @param data 广告数据
 */
export const updateAdvertisement = (id: string, data: any) => {
  return request({
    url: `${API.CLASSES}/Advertisement/${id}`,
    method: 'PUT',
    data
  });
};

/**
 * 删除广告
 * @param id 广告ID
 */
export const deleteAdvertisement = (id: string) => {
  return request({
    url: `${API.CLASSES}/Advertisement/${id}`,
    method: 'DELETE'
  });
};

/**
 * 获取广告详情
 * @param id 广告ID
 */
export const getAdvertisementDetail = (id: string) => {
  return request({
    url: `${API.CLASSES}/Advertisement/${id}`,
    method: 'GET'
  });
};

/**
 * 更新广告状态
 * @param id 广告ID
 * @param status 状态值（0-未启用，1-已启用）
 */
export const updateAdvertisementStatus = (id: string, status: number) => {
  return request({
    url: `${API.CLASSES}/Advertisement/${id}`,
    method: 'PUT',
    data: { status }
  });
}; 